package org.nvframe.manager;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @author Nik Van Looy
 */
public class ConfigManager {

	private static final ConfigManager _instance = new ConfigManager();

	public static ConfigManager getInstance() {
		return _instance;
	}
	
	private  Map<String, Boolean> functions;

	private ConfigManager() {
		functions = new HashMap<String, Boolean>();
	}

	/**
	 * Set a specified function true or false
	 * 
	 * @param id The name of the function
	 * @param active The state of the function
	 */
	public void setFunction(String id, boolean active) {
		if(getActive("debugMode"))
			System.out.println("ConfigManager set function | " + id + " = " + String.valueOf(active));
		functions.put(id, active);
	}

	/**
	 * Toggle the state of a specified function
	 * 
	 * @param id The name of the function
	 */
	public void toggleActive(String id) {
		Boolean active = functions.get(id);
		active = active == null ? false : !active;
		
		setFunction(id, active);
	}
	
	/**
	 * Get the state of a function from a specified id
	 * 
	 * @param id The name of the function
	 * @return The state of the function
	 */
	public boolean getActive(String id) {
		Boolean active = functions.get(id);
		return active == null ? false : active;
	}

}
